<?php

/**
 * 检查用户邮箱，是否被使用
 * @author dinglin
 *
 */
apf_require_controller("HrAbstract");
class Hr_Ajax_CheckEmailController extends HrAbstractController {

    public function handle_request() {
        $params = $this->request->get_parameters();
        $params['email'] = trim($params['email']);
        $fix   = '/^[0-9a-zA-Z]+(?:[\_\-][a-z0-9\-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\.[a-zA-Z]+$/i';
        if(preg_match($fix,$params['email'])){
            $bll = new Bll_Hr_User();
            $code = $bll->check_email_is_used($params['email']);
            if($code){
                $this->json_encode(1,"该邮箱已被使用");//被使用
            }else{
                $this->json_encode(0,"");//没被使用
            }
        }else{
            $this->json_encode(2,"邮箱格式不正确");//没被使用
        }
    }

}